package main

import (
	"net"
)

/**
grpc 直链模式  服务端
*/
//reference https://www.cnblogs.com/YaoDD/p/5504881.html

import (
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"log"
)

const (
	port = ":50051"
)

type server struct{}

func (s *server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, error) {
	return &HelloReply{Message: "Hello 1111111 " + in.Name}, nil
}

func serverMain() {
	lis, err := net.Listen("tcp", port)
	if err != nil {
		log.Fatal("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	RegisterGreeterServer(s, &server{})
	s.Serve(lis)
}
